<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="file" onchange='handleUploadFile()' id="upload" accept="image/*" multiple>
    <img id="img" src="" alt="">
</body>
<script>
    function handleUploadFile() {
        console.log(document.getElementById('upload').files);
        let fileObj = document.getElementById('upload').files[0]
        console.log(fileObj);
        let reader = new FileReader()
        reader.readAsDataURL(fileObj)
        reader.onload = function(e) {
            console.log(e.target);
            document.getElementById('img').src = e.target.result
        }
    }
</script>

</html>